package com.durian.base.rxhttp.await

/**
 * 说明：异常返回值
 * <p/>
 * 作者：Fanly
 * <p/>
 * 类型：Class
 * <p/>
 * 时间：2020/04/25 18:07
 * <p/>
 * 版本：version 1.0
 */
internal class AwaitErrorReturn<T>(
        private val iAwait: IAwait<T>,
        private val map: (Throwable) -> T
) : IAwait<T> {
    override suspend fun await(): T = try {
        iAwait.await()
    } catch (e: Throwable) {
        map(e)
    }
}